package com.zhanggm.s3.core.config;

import com.zhanggm.s3.core.exception.BizException;
import com.zhanggm.s3.core.utils.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常拦截
 */
@RestControllerAdvice
public class GlobalExeceptHandler {

    @ExceptionHandler(Exception.class)
    public AjaxResult handlerException(Exception e) {
        e.printStackTrace();
        return AjaxResult.error(e.getMessage());
    }

    @ExceptionHandler(BizException.class)
    public AjaxResult handlerBizException(Exception e) {
        e.printStackTrace();
        return AjaxResult.error(e.getMessage());
    }
}
